package dtime

import (
	"github.com/robfig/cron/v3"
	"video/pkg/dao/mysql"
	"video/pkg/dao/redis"
)

const (
	EveryDayPass1Minute = "0 */5 * * * ?"
)

type ServerTime struct {
	c *cron.Cron
	M mysql.Mysql
	R redis.Redis
}

func NewServerTime(val *cron.Cron) *ServerTime {
	return &ServerTime{
		c: val,
		M: mysql.NewMysql(),
		R: redis.NewRedis(),
	}
}

func (s ServerTime) RunServer() {
	//注册定时任务
	//定时更新 video
	s.c.AddFunc(EveryDayPass1Minute, s.UpdateVideoInfo)
}
